package httpx

import "github.com/valyala/fastjson"

type (
	JSONValue  = fastjson.Value
	JSONObject = fastjson.Object
)

// ProcessJSONDocument 以JSON格式处理下载流
func ProcessJSONDocument(process func(jv *JSONValue) error) ProcessFunc {
	return ProcessBytes(func(data []byte) error {
		jv, err := fastjson.ParseBytes(data)
		if err != nil {
			return err
		}
		return process(jv)
	})
}
